#include "Cantilever.h"
#include <vector>

Cantilever::Cantilever()
{

}


Cantilever::Cantilever(int BeamLength)
{
    SetLength(BeamLength);
}

Cantilever::~Cantilever()
{
}


int Cantilever::GetMoment()
{
    int AllLoadingsMoments = 0;

    std::vector<Loadings>::iterator BeamLoadings;
    for(BeamLoadings = m_loads.begin(); BeamLoadings != m_loads.end(); ++BeamLoadings)
    {
        AllLoadingsMoments += (BeamLoadings->GetLoadLocation() * BeamLoadings->GetLoadValue());
    }

    //The -1 is to account for the -force being the downward direction.  This hopefully will cause the reaction force to be reported correctly.
    int LoadingMoment = (-1 * AllLoadingsMoments);

    return LoadingMoment;

}

int Cantilever::GetReaction()
{
    int AllLoads = 0;
    std::vector<Loadings>::iterator BeamLoadings;
    for(BeamLoadings = m_loads.begin(); BeamLoadings != m_loads.end(); ++BeamLoadings)
    {
        AllLoads += BeamLoadings->GetLoadValue();
    }

    int ReactionA = (-1 * AllLoads);
    return ReactionA;
}

void Cantilever::AddLoads(int LoadValue, int LoadLocation)
{
    AddBeamLoad(LoadValue, LoadLocation);
}
